#include <atomic>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
using namespace std;

int main(){
  uint64_t NT;
  cin >> NT;
  const uint64_t M = 100'000'000;
  vector<thread> vt;
#if 0
  auto worker = [NT,M](volatile atomic<uint64_t>* counter, uint64_t id){
    for(uint64_t i = id; i < M; i += NT){
      ++(*counter);
    }
  };
#else
  mutex mtx;
  auto worker = [NT,M,&mtx](volatile atomic<uint64_t>* counter, uint64_t id){
    for(uint64_t i = id; i < M; i += NT){
      lock_guard<mutex> lg(mtx);
      ++(*counter);
    }
  };
#endif

  atomic<uint64_t> counter(0);
  vt.clear();
  for(uint64_t id = 0; id < NT; ++id){
    vt.emplace_back(worker, &counter, id);
  }
  for(auto& t : vt){
    t.join();
  }
}